//
//  TabBarController.swift
//  NetMusic
//
//  Created by PushMeBaby on 16/2/2.
//  Copyright © 2016年 CoderC. All rights reserved.
//

import UIKit

class TabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let homeVc = HomeViewController()
        
        addChildViewController(homeVc, title: "发现音乐", imageName: "cm2_btm_icn_discovery", selectImageName: "cm2_btm_icn_discovery_prs")
        
        
        let myMusicVc = MyMusicViewController()
        
        addChildViewController(myMusicVc, title: "我的音乐", imageName: "cm2_btm_icn_music", selectImageName: "cm2_btm_icn_music_prs")
        
        
        let friendVc = FriendViewController()
        
        addChildViewController(friendVc, title: "朋友", imageName: "cm2_btm_icn_friend", selectImageName: "cm2_btm_icn_friend_prs")
        
        
        let profileVc = ProfileViewController()
        
        addChildViewController(profileVc, title: "账号", imageName: "cm2_btm_icn_account", selectImageName: "cm2_btm_icn_account_prs")
        
        UITabBar.appearance().tintColor = UIColor.whiteColor()
        
        let image = ImageViewColor(OSColor(39, green: 43, blue: 45))
        UITabBar.appearance().backgroundImage = image
    }
    
    
    func addChildViewController(childController: UIViewController, title: String, imageName: String, selectImageName: String) {
        
        childController.title = title
        childController.tabBarItem.title = title
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: selectImageName)
        
        let nav = NavigationController()
        nav.addChildViewController(childController)
        
        addChildViewController(nav)
        
    }
    
    
    
}
